import { createRouter,createWebHashHistory } from 'vue-router';
import Layout from '../view/home.vue'
const routes = [ 
  {
     path:'/',
     redirect:'/home',
   },
   
   {
     path:'/home',
     component: Layout,
     redirect:'/index',
     children:[
       {
         path:'/index',
         meta:{
           title:'新闻首页',
           menuShow:true,
           routePath:"/index"
         },
         component: () => import('../view/index/index.vue'),
       },
       {
         path:'/analysis',
         meta:{
           title:'政策分析',
           menuShow:true,
           routePath:"/analysis"
         },
         component: () => import('../view/index/analysis.vue'),
       },
      {
        path:'/violation',
        meta:{
          title:'违规曝光',
          menuShow:true,
          routePath:"/violation"
        },
        component: () => import('../view/index/analysis.vue'),
      },
      {
        path:'/information',
        meta:{
          title:'行业资讯',
          menuShow:true,
          routePath:"/information"
        },
        component: () => import('../view/index/analysis.vue'),
      },
      {
        path:'/expertise',
        meta:{
          title:'专业知识',
          menuShow:true,
          routePath:"/expertise"
        },
        component: () => import('../view/index/analysis.vue'),
      },
       {
        path:'/analysisDetail',
        meta:{
          title:'详情',
          menuShow:false,
          routePath:"/analysis"
        },
        component: () => import('../view/index/analysisDetail.vue'),
       },
        {
         path:'/export',
         meta:{
           title:'专家服务',
           menuShow:true,
           routePath:"/export"
         },
         component: () => import('../view/index/export.vue'),
       },
       {
         path:'/enterprises',
         meta:{
           title:'名企名品',
           menuShow:true,
           routePath:"/enterprises"
         },
         component: () => import('../view/index/enterprises.vue'),
       },
       {
        path:'/enterprisesDetail',
        meta:{
          title:'企业详情',
          menuShow:false,
          routePath:"/enterprises"
        },
        component: () => import('../view/index/enterprisesDetail.vue'),
      },
       {
         path:'/recovery',
         meta:{
           title:'产品召回',
           menuShow:true,
           routePath:"/recovery"
         },
         component: () => import('../view/index/recovery.vue'),
       },
       {
        path:'/recoveryDetail',
        meta:{
          title:'产品召回',
          menuShow:false,
          routePath:"/recovery"
        },
        component: () => import('../view/index/recoveryDetail.vue'),
      },
      //  {
      //    path:'/login',
      //    meta:{
      //      title:'登录/注册',
      //      menuShow:true,
      //      routePath:"/login"
      //    },
      //    component: () => import('../view/index/login.vue'),
      //  },
     ]
   },
 ]

const router = createRouter({
  mode: 'hash',
  history: createWebHashHistory(import.meta.env.VITE_BASE_PATH),
  routes
})
router.beforeEach((to,from,next)=>{ 
    window.scroll(0, 0);
    next()
})
export default router
